//
//  UIColor_Ex.swift
//  DawnFoundation
//
//  Created by 崔成成 on 2021/8/14.
//

import UIKit

extension UIColor {
    
    public static func hex(_ val: Int, alpha: CGFloat = 1)-> UIColor{
        return UIColor(red: ((CGFloat)((val & 0xFF0000) >> 16)) / 255.0,
                       green: ((CGFloat)((val & 0xFF00) >> 8)) / 255.0,
                       blue: ((CGFloat)(val & 0xFF)) / 255.0,
                       alpha: alpha)
    }
    
    public static func rgb(r: CGFloat, g: CGFloat, b: CGFloat)-> UIColor{
        return UIColor(red: r/255.0, green: g/255.0, blue: b/255.0, alpha: 1.0)
    }
    
    public static func rgbA(r: CGFloat, g: CGFloat, b: CGFloat, a: CGFloat)-> UIColor{
        return UIColor(red: r/255.0, green: g/255.0, blue: b/255.0, alpha: a)
    }
    
    public static func rgbOne(_ rgb: CGFloat)-> UIColor{
        return UIColor(red: rgb/255.0, green: rgb/255.0, blue: rgb/255.0, alpha: 1.0)
    }
}
